/**
 * 启动APP入口
 * https://github.com/facebook/react-native
 * @flow
 */
//导入基础组件
import React, {
  Component
} from 'react'
//导入本地存储和警告显示
import {
  AsyncStorage,
  YellowBox
} from 'react-native'
//导入本地绑定事件
import {
  bindActionCreators
} from 'redux'
import {
  connect
} from 'react-redux'
import * as appActions from '../actions/app'
//导入导航器
import Locker from '../navigation/index'

//本地数据抹除
AsyncStorage.multiRemove(['entered', 'user'])
class AppContainer extends Component {
  constructor(props) {
    super(props)
    this.state = {
      username: '',
      psw: ''
    };
    YellowBox.ignoreWarnings([
      'Warning: componentWillMount is deprecated',
      'Warning: componentWillReceiveProps is deprecated',
    ]);
  }
  componentDidMount() {
    this.props.willEnterApp()
  }
  render() {
    return (
      <Locker />
    );
  }
}
//获取基础属性
function mapStateToProps(state) {
  return {
    booted: state.booted,
    logined: state.logined,
    entered: state.entered,
    banners: state.banners
  }
}
//所有的参数进行绑定传递给这个组件
function mapDispatchToProps(dispatch) {
  return bindActionCreators(appActions, dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(AppContainer)